<template>
  <div class="addcart">
    <span class="iconfont icon-kefu"></span>
    <router-link to="/cart"
      ><span class="iconfont icon-gouwuche">
        <span id="nnn">0</span>
      </span></router-link
    >
    <span class="iconfont icon-wujiaoxingkong"></span>

    <div class="sku-container">
        <van-sku
          v-model="showBase"
          :sku="skuData.sku"
          :goods="skuData.goods_info"
          :goods-id="skuData.goods_id"
          :hide-stock="skuData.sku.hide_stock"
          :quota="skuData.quota"
          :quota-used="skuData.quota_used"
          :initial-sku="initialSku"        
          reset-stepper-on-hide
          reset-selected-sku-on-hide
          disable-stepper-input
          :close-on-click-overlay="closeOnClickOverlay" 
          :custom-sku-validator="customSkuValidator"  
          @buy-clicked="onBuyClicked"
          @add-cart="onAddCartClicked"
        />
        <van-button
          block
          type="primary"
          @click="showBase = true"
          class="anniu1"
        >
          加入购物车
        </van-button>

        <van-button
          block
          type="primary"
          @click="showBase = true"
          class="anniu2"
        >
          立即购买
        </van-button>
      </div> 
  </div>
</template>

<script>

import skuData from './data';

export default {
  name: "Addcart",
  data() {
    return {
      skuData:skuData,
      showBase: false,
      showCustom: false,
      showStepper: false,
      showSoldout: false,
      closeOnClickOverlay: true,
      initialSku: {
        s1: '30349',
        s2: '1193',
        selectedNum: 3
      },
      customSkuValidator: () => '请选择xxx!', 
    };
  },
 
  methods: {
    onBuyClicked(data) {
      this.$toast('buy:' + JSON.stringify(data));
      console.log(JSON.stringify(data))
    },
 
    onAddCartClicked(data) {
      this.$toast('add cart:' + JSON.stringify(data));
    }, 
  }
};

</script>

<style scoped>
@import url(../assets/font_2617715_6v9jnn2bb0y/iconfont.css);
.addcart {
  width: 100%;
  height: 0.47rem;
  border-top: 0.01rem solid gainsboro;
  background-color: white;
  position: fixed;
  bottom: 0;
}
.addcart > span:nth-child(1) {
  width: 0.25rem;
  height: 100%;
  position: absolute;
  left: 0.15rem;
  font-size: 0.25rem;
  line-height: 0.47rem;
  color: red;
}
.addcart > a:nth-child(2) > span {
  width: 0.25rem;
  height: 100%;
  position: absolute;
  left: 0.57rem;
  font-size: 0.25rem;
  line-height: 0.47rem;
  color: black;
}
.addcart > a:nth-child(2) > span > span {
  display: block;
  width: 0.12rem;
  height: 0.12rem;
  border-radius: 50%;
  background-color: red;
  font-size: 0.1rem;
  text-align: center;
  line-height: 0.12rem;
  position: absolute;
  top: 0.07rem;
  right: -0.03rem;
  color: white;
}
.addcart > span:nth-child(3) {
  width: 0.25rem;
  height: 100%;
  position: absolute;
  left: 0.95rem;
  font-size: 0.25rem;
  line-height: 0.47rem;
}
.anniu1{
    width: 1.08rem;
  height: 0.36rem;
  background-color: red;
  position: absolute;
  left: 1.4rem;
  top: 0.06rem;
  border-radius: 0.18rem;
  text-align: center;
  line-height: 0.36rem;
  color: white;
  font-size: 0.14rem;
  /* padding: 0 15px; */
  border: 0rem;
}
.anniu2{
  width: 1.08rem;
  height: 0.36rem;
  background-color: #cc9656;
  position: absolute;
  left: 2.55rem;
  top: 0.06rem;
  border-radius: 0.18rem;
  text-align: center;
  line-height: 0.36rem;
  font-size: 0.14rem;
  color: white;
  border: 0rem;
}
</style>